﻿using SpreadsheetLight;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ExcelHandler
{
    public abstract class ExcelStyle : SLStyle
    {
        public ExcelStyle()
        {
            // common styles
            this.Alignment.Horizontal = DocumentFormat.OpenXml.Spreadsheet.HorizontalAlignmentValues.Left;
            this.Alignment.Vertical = DocumentFormat.OpenXml.Spreadsheet.VerticalAlignmentValues.Top;
            this.Font.FontName = "Calibri";
            this.SetWrapText(true);

            this.Border.SetLeftBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);
            this.Border.SetRightBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);
            this.Border.SetTopBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);
            this.Border.SetBottomBorder(DocumentFormat.OpenXml.Spreadsheet.BorderStyleValues.Thin, Color.Black);
            
        }
    }

    public class HeaderCellStyle : ExcelStyle
    {
        public HeaderCellStyle()
        {
            this.Fill.SetPattern(DocumentFormat.OpenXml.Spreadsheet.PatternValues.Solid,
                                                            Color.Firebrick, Color.White);
            this.Font.Bold = true;
            this.Font.FontColor = Color.White;
            this.Font.FontSize = 12;

            // override
            this.Alignment.Vertical = DocumentFormat.OpenXml.Spreadsheet.VerticalAlignmentValues.Center;

           
            
        }
    }

    public class IncomeDataCellStyle : ExcelStyle
    {
        public IncomeDataCellStyle()
        {
            this.Fill.SetPattern(DocumentFormat.OpenXml.Spreadsheet.PatternValues.Solid,
                                        Color.LightGreen, Color.White);
            this.Font.Bold = false;
            this.Font.FontColor = Color.Black;
            this.Font.FontSize = 10;
        }
    }

    public class IncomeDataCellStyleDeleted : IncomeDataCellStyle
    {
        public IncomeDataCellStyleDeleted()
        {
            this.Font.Strike = true;
        }
    }

    public class ExpenseDataCellStyle : ExcelStyle
    {
        public ExpenseDataCellStyle()
        {
            this.Fill.SetPattern(DocumentFormat.OpenXml.Spreadsheet.PatternValues.Solid,
                                                                Color.LightPink, Color.White);
            this.Font.Bold = false;
            this.Font.FontColor = Color.Black;
            this.Font.FontSize = 10;
        }
    }

    public class ExpenseDataCellStyleDeleted : ExpenseDataCellStyle
    {
        public ExpenseDataCellStyleDeleted()
        {
            this.Font.Strike = true;
        }
    }

    public class SummaryKeyStyle : ExcelStyle
    {
        public SummaryKeyStyle()
        {
            this.Fill.SetPattern(DocumentFormat.OpenXml.Spreadsheet.PatternValues.Solid,
                                        Color.Black, Color.White);
            this.Font.Bold = true;
            this.Font.FontColor = Color.White;
            this.Font.FontSize = 12;

            // override
            this.Alignment.Vertical = DocumentFormat.OpenXml.Spreadsheet.VerticalAlignmentValues.Center;

        }
    }

    public class SummaryValueStyle : ExcelStyle
    {
        public SummaryValueStyle()
        {
            this.Fill.SetPattern(DocumentFormat.OpenXml.Spreadsheet.PatternValues.Solid, Color.SteelBlue,
                                        Color.White);
            this.Font.Bold = false;
            this.Font.FontColor = Color.White;
            this.Font.FontSize = 12;

            // override
            this.Alignment.Vertical = DocumentFormat.OpenXml.Spreadsheet.VerticalAlignmentValues.Center;
        }
    }

    public class LegendKeyStyle : ExcelStyle
    {
        public LegendKeyStyle()
        {
            this.Fill.SetPattern(DocumentFormat.OpenXml.Spreadsheet.PatternValues.Solid,
                                        Color.Black, Color.White);
            this.Font.Bold = true;
            this.Font.FontColor = Color.White;
            this.Font.FontSize = 12;

            // override
            this.Alignment.Vertical = DocumentFormat.OpenXml.Spreadsheet.VerticalAlignmentValues.Center;
            this.Alignment.Horizontal = DocumentFormat.OpenXml.Spreadsheet.HorizontalAlignmentValues.Center;

        }
    }

    public class IncomeLegendValueStyle : IncomeDataCellStyle
    {
        public IncomeLegendValueStyle()
        {
            // override
            this.Alignment.Vertical = DocumentFormat.OpenXml.Spreadsheet.VerticalAlignmentValues.Center;
            this.Alignment.Horizontal = DocumentFormat.OpenXml.Spreadsheet.HorizontalAlignmentValues.Center;
        }
    }

    public class ExpenseLegendValueStyle : ExpenseDataCellStyle
    {
        public ExpenseLegendValueStyle()
        {
            // override
            this.Alignment.Vertical = DocumentFormat.OpenXml.Spreadsheet.VerticalAlignmentValues.Center;
            this.Alignment.Horizontal = DocumentFormat.OpenXml.Spreadsheet.HorizontalAlignmentValues.Center;
        }
    }

    

    public static class CellWidthConstants
    {
        public const int TransactionModeWidth = 20;
        public const int TransactionDateWidth = 20;
        public const int BankDateWidth = 15;
        public const int ChequeNoWidth = 15;
        public const int ChequeDrawnOnBankWidth = 20;
        public const int ChequeDateWidth = 15;
        public const int TransactionBankWidth = 20;
        public const int AmountWidth = 17;
        public const int LedgerBalanceWidth = 17;
        public const int NarrationWidth = 20;
        public const int HeadDetailsWidth = 20;
        public const int BuildingWidth = 10;
        public const int FlatNoWidth = 10;
        public const int ReceiptVoucherNoWidth = 30;
        public const int TransactionIdWidth = 15;
        public const int CreatedByWidth = 15;
        public const int UpdatedByWidth = 15;
    }
}
